<?php
require_once('common.php');
//************************执行代码开始*************************

if($_GET['type']=="upload"){
$extension=explode('.',$_FILES['file']['name']);
copy($_FILES['file']['tmp_name'], '../style/hero-bg.png');
echo"<script language='javascript'>alert('背景上传成功');window.location.href='template.php';</script>";
}

if($do=$_POST['do']){
	foreach($_POST as $k=> $value){
		$db->query("insert into {$prefix}webconfigs set vkey='".safestr($k)."',value='".safestr($value)."' on duplicate key update value='".safestr($value)."'");
	}
	if($rows=$db->get_results("select * from {$prefix}webconfigs")){
		foreach($rows as $row){
			$webconfig[$row['vkey']]=$row['value'];
		}
		C($webconfig);
	}

	echo"<script language='javascript'>alert('保存成功！');window.location.href='template.php';</script>";
}
if($_GET['template']=='yrf'){
	$path="other/index/index_black.php";
	 mysql_query(("insert into {$prefix}webconfigs set vkey='webindex',value='$path' on duplicate key update value='$path'"));
	 echo"<script language='javascript'>alert('模板更换成功！');window.location.href='template.php';</script>";
}elseif($_GET['template']=='tgv2'){
	$path="other/index/index_tg.php";
	 mysql_query(("insert into {$prefix}webconfigs set vkey='webindex',value='$path' on duplicate key update value='$path'"));
	 echo"<script language='javascript'>alert('模板更换成功！');window.location.href='template.php';</script>";
}elseif($_GET['template']=='menghui'){
	$path="other/index/index_menghui.php";
	 mysql_query(("insert into {$prefix}webconfigs set vkey='webindex',value='$path' on duplicate key update value='$path'"));
	 echo"<script language='javascript'>alert('模板更换成功！');window.location.href='template.php';</script>";
}elseif($_GET['template']){
	$path="other/index/index_tgv2.php";
	 mysql_query(("insert into {$prefix}webconfigs set vkey='webindex',value='$path' on duplicate key update value='$path'"));
	 echo"<script language='javascript'>alert('模板更换成功！');window.location.href='template.php';</script>";
}
$template=require("../other/index/config.php");
//**************************执行代码开始*******************************
C('pageid','template');
C('webtitle','模板管理');
include_once 'common.head.php';
?>
<p>1.梦回新版模版换LOGO、换友链教程<a href="http://logohelp.52hm.win">点这里>>></a></p>
<p>2.截至2016年8月3日，后三套模版JS出现无法加载，为天高服务器问题，请等待天高修复</p>
<p>3.已将梦回新版模版做云盾加速，如果速度还是不满意，捐赠版提供腾讯云550+节点不秒开退款</p>
<p>PS:我不给普通用户用腾讯云不是因为想赚钱，而是怕像榴莲云一样挨小人CC导致大家都不能用！</p>
		<div class="wrapper wrapper-content animated fadeInRight">
              <!-- page start--><!-- 网站设置 -->
                      <div class="row">
					  <div class="col-lg-12">
                      <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>当前模板 </h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                          <div class="ibox-content">
							<table cellspacing="20" cellpadding="0" width="80%" border="0">
    <tr>
      <td width="42%">
	  <img src="<?=$template['template_img']?>" width="240" height="180"  border="1" />	  </td>
	  <td width="58%">
	  <?=$template['template_name']?><br>
	  作者：<a href="<?=$template['template_url']?>"><?=$template['template_author']?></a><br>
	  <?=$template['template_readme']?>
	  <br>
	  <a href="?templates=tg&set=1">设置</a>
	  </td>
    </tr>
</table>
<?php
if($_GET['templates']=='tg' && $_GET['set']=='1'){
?>
<div class="list-group-item">
<div class="input-group">
<div class="input-group-addon">主页电脑版背景</div>
<div class="form-control">
<form name="form1" method="post" action="?type=upload" enctype="multipart/form-data">
          <input type="hidden" name="name" value="hero-bg.jpg">
										<input type="file" name="file" id="file" size="20" class="tx1" value=""/>
										
</div>

</div>
<div class="list-group-item">
								<input type="submit" name="submit" value="上传背景" class="btn btn-primary btn-block">
								</div>
								</form>
</div>
<?php
}
?>

						</div>
						<hr>
						<div class="ibox-title">
                        <h5>模板库 </h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
					<div class="ibox-content">
					<table cellspacing="0" cellpadding="0" width="99%" border="0" class="adm_tpl_list">
<tr>      
<td align="center">
	  <a href="?template=menghui">
	  <img alt="点击使用该模板" src="/style/other/menghui.png" width="180" height="150" border="0" />
	  </a><br />
	  梦回新版      <span> | <a href="?template=menghui">使用</a></span>
      </td>
<td align="center">
	  <a href="?template=tg">
	  <img alt="点击使用该模板" src="/style/other/preview.png" width="180" height="150" border="0" />
	  </a><br />
      天高模板      <span> | <a href="?template=tg">使用</a></span>
      </td>
	  <td align="center">
	  <a href="?template=yrf">
	  <img alt="点击使用该模板" src="/style/other/macbook-pro.png" width="180" height="150" border="0" />
	  </a><br />
      鱼儿飞炫黑      <span> | <a href="?template=yrf">使用</a></span>
      </td>
	  <td align="center">
	  <a href="?template=tgv2">
	  <img alt="点击使用该模板" src="/style/other/property-img.png" width="180" height="150" border="0" />
	  </a><br />
      简洁大气      <span> | <a href="?template=tgv2">使用</a></span>
      </td>
</table>

					</div>
						</div>
				</div>

</div></div>
	  <?php
include_once 'common.foot.php';
?>